<?php 

header("Content-type: text/html; charset=utf-8"); 


// var_dump($pdo);

try{
	$pdo = new PDO("mysql:host=127.0.0.1;dbname=stu;charset=utf8","root","");
	$mysecuredata=14;
	$pdo->query("Select * from table where id=".$mysecuredata);
}catch(PDOException  $e ){
	echo "Error: ".$e;
	exit();
}

$pdo->query("set names utf8");

$sql = "select * from stu";

$res = $pdo->query($sql);

if (!$res) {
	echo "执行失败，错误代码：".$pdo->errorCode();
	echo "错误信息：".$pdo->errorInfo()[2];
	exit();
}

$userlist = $res->fetchAll(PDO::FETCH_ASSOC);

var_dump($userlist);














 ?>